------------------ fgui require start ------------------
------------------  fgui require end  ------------------
local UIGuildSkin = Class("UIGuildSkin");

function UIGuildSkin:ctor(com)
    ------------------ fgui事件绑定start ------------------
    self:bindChild(com);
    self.btnBack.onClick:Add(self.onTouch_BtnBack, self);
    self.btn_Guildhall.onClick:Add(self.onTouch_Btn_Guildhall, self);
    self.btn_gvg[EnumConst.GuildBattlePlusType.Championship].onClick:Add(self.onTouch_Btn_gvg, self);
    self.btn_gvg[EnumConst.GuildBattlePlusType.Territory].onClick:Add(self.onTouch_Btn_Guildcitybattle, self);
    self.bgclose.onClick:Add(self.onTouch_CloseBGPTips, self);
    self.activeTipBtn1.onClick:Add(self.onTouch_BtnActiveTip1,self);
    self.activeTipBtn2.onClick:Add(self.onTouch_BtnActiveTip2,self);
    self.go.onClick:Add(self.onTouch_Btn_gvg, self);
    self.btn_Guildleader.onClick:Add(self.onTouch_Btn_Guildleader, self);
    self.btn_Guildshop.onClick:Add(self.onTouch_Btn_Guildshop, self);
    self.btn_Guildinvestment.onClick:Add(self.onTouch_Btn_Guildinvestment, self);
    self.btn_Guildwish.onClick:Add(self.onTouch_Btn_Guildwish, self);
    self.BtnRank.onClick:Add(self.onTouch_BtnRank, self);
    self.BtnGift.onClick:Add(self.onTouch_BtnGift, self);
    self.BtnRobList.onClick:Add(self.onTouch_BtnRobList, self)
    self.BtnRegistration.onClick:Add(self.onTouch_BtnRegistration, self)
    self.btn_guild_tech.onClick:Add(self.onTouch_BtnGuildTech, self)
    self.BtnGuildTask.onClick:Add(self.onTouch_BtnGuildTask, self)
    self:init();
    ------------------  fgui事件绑定end  ------------------
    self.com_Guildhall.onClick:Add(self.onTouch_Btn_Guildhall, self);
    self.com_gvg.onClick:Add(self.onTouch_Btn_gvg, self);
    self.com_Guildleader.onClick:Add(self.onTouch_Btn_Guildleader, self);
    self.com_Guildshop.onClick:Add(self.onTouch_Btn_Guildshop, self);
    self.com_Guildinvestment.onClick:Add(self.onTouch_Btn_Guildinvestment, self);
    self.com_Guildwish.onClick:Add(self.onTouch_Btn_Guildwish, self);
    self.btnBackground.onClick:Add(self.onTouch_Btn_background, self);
end

function UIGuildSkin:bindChild(com)
    ------------------ fgui变量绑定start ------------------
    self.fguiObj = com;
    self.btn_gvg = {};
    self.text_title = com:GetChild("Text_title");
    self.map = com:GetChild("map"):GetChildAt(0);
    self.btnBack = com:GetChild("BtnBack");
    self.com_Guildhall = self.map:GetChild("Com_Guildhall");
    self.com_Guildleader = self.map:GetChild("Com_Guildleader");
    self.com_gvg = self.map:GetChild("Com_gvg");
    self.com_Guildshop = self.map:GetChild("Com_Guildshop");
    self.com_Guildinvestment = self.map:GetChild("Com_Guildinvestment");
    self.com_Guildwish = self.map:GetChild("Com_Guildwish");
    self.btn_Guildhall = self.map:GetChild("Btn_Guildhall");
    self.btn_gvg[EnumConst.GuildBattlePlusType.Championship] = self.map:GetChild("Btn_gvg");
    self.btn_gvg[EnumConst.GuildBattlePlusType.Territory] = self.map:GetChild("Btn_Guildcitybattle");
    self.btn_Guildleader = self.map:GetChild("Btn_Guildleader");
    self.btn_Guildshop = self.map:GetChild("Btn_Guildshop");
    self.btn_Guildinvestment = self.map:GetChild("Btn_Guildinvestment");
    self.btn_Guildwish = self.map:GetChild("Btn_Guildwish");
    self.BtnRank = com:GetChild("BtnRank");
    self.BtnGift = com:GetChild("n57");
    self.BtnRobList = com:GetChild("BtnRobList")
    self.BtnRegistration = com:GetChild("BtnRegistration")
    self.BtnGuildTask = com:GetChild("BtnGuildTask")
    self.go = com:GetChild("showTips"):GetChild("go")
    self.bgclose = com:GetChild("showTips"):GetChild("bgclose")
    self.Registration = com:GetController("Registration")
    self.fightTipsController = com:GetController("fightTips")
    self.activeTipBtn1 = self.map:GetChild("Btn_Help1")
    self.activeTipBtn2 = self.map:GetChild("Btn_Help2")

    -- self.BtnRobList.visible = false
    -- if plunderHandler.IsOpen() then
    --if FuncOpenManager.isOpen(Config.FuncOpenType.Rob, false) then
    --    self.BtnRobList.visible = true
    --else
    --    self.BtnRobList.visible = false
    --end
    self.btn_guild_tech = self.map:GetChild("Btn_GuildTech")

    self.ldrFlag1 = com:GetChild("ldr_flag01");
    self.ldrFlag2 = com:GetChild("ldr_flag02");
    self.effectGuildAlly = com:GetTransition("Effect_GuildAlly");
    self.effectReset = com:GetTransition("Effect_Reset");
    self.effectCtrl = com:GetController("effect");
    self.effectCtrl.selectedIndex = 0;
    self.btnBackground = com:GetChild("Btn_blackbackground");
    ------------------  fgui变量绑定end  ------------------
end

function UIGuildSkin:init()
    --self:updateGuildBattleState();
    self:updateShowGiftBtn()
    self:updateAutoOpenGift()
    self:updateGuildBattlePlusState(EnumConst.GuildBattlePlusType.Territory);
    self:updateGuildBattlePlusState(EnumConst.GuildBattlePlusType.Championship);
    self:showGuildBattlePlusTips();
    self:updateGuildBattlePlusApply();
    self:showJoinSucEffect(1);
    self.btn_Guildwish.text = getLanguage("GuildInvestment_1091");
    self.btn_Guildinvestment.text = getLanguage("GuildInvestment_1090");
    self.btn_Guildshop.text = getLanguage("GuildInvestment_1092");
    self.btn_Guildhall.text = getLanguage("GuildInvestment_1089");
    self.btn_Guildleader.text = getLanguage("GuildInvestment_1093");
    self.BtnGift.text = getLanguage("GuildGiftName");
    self.text_title.text = getLanguage("GuildInvestment_1095");
    self.btn_Guildhall:GetChild("UIRedDots"):GetController("c1").selectedIndex = logicMgr.GuildManager.hasApplyGuildMembers() and 2 or 0;
    UIRedDots.addViewListen(PanelResNames.UIGuild, self.fguiObj.name .. self.btn_Guildhall.name, self.btn_Guildhall, Config.RedDotsType.GuildApply, 1);
    UIRedDots.addViewListen(PanelResNames.UIGuild, self.fguiObj.name .. self.btn_Guildleader.name, self.btn_Guildleader, Config.RedDotsType.GuildBoss);
    UIRedDots.addViewListen(PanelResNames.UIGuild, self.fguiObj.name .. self.btn_Guildwish.name, self.btn_Guildwish, Config.RedDotsType.GuildWish);
    UIRedDots.addViewListen(PanelResNames.UIGuild, self.fguiObj.name .. self.BtnRobList.name, self.BtnRobList, Config.RedDotsType.GuildHelpRob)
    UIRedDots.addViewListen(PanelResNames.UIGuild, self.fguiObj.name .. self.btn_guild_tech.name, self.btn_guild_tech, Config.RedDotsType.GuildTech)
    UIRedDots.addViewListen(PanelResNames.UIGuild, self.fguiObj.name .. self.BtnRegistration.name, self.BtnRegistration, Config.RedDotsType.GuildBattlePlusApply)
    UIRedDots.addViewListen(PanelResNames.UIGuild, self.fguiObj.name .. self.BtnGuildTask.name, self.BtnGuildTask, Config.RedDotsType.GuildTask)
    UIRedDots.addViewListen(PanelResNames.UIGuild, self.fguiObj.name .. self.BtnGift.name, self.BtnGift, Config.RedDotsType.GuildGift)


    ListenEvent(Config.EventType.Fresh_UnionWarBaseInfo, self.updateGuildBattleState, self);
    ListenEvent(Config.EventType.Fresh_UnionWarPlusBaseInfo, self.updateGuildBattlePlusState, self);
    ListenEvent(Config.EventType.GuildGiftRefresh, self.updateShowGiftBtn, self);
    ListenEvent(Config.EventType.Union_Info_Change, self.OpenGuildPanel, self);
    ListenEvent(Config.EventType.Fresh_UnionWarPlusQualification, self.updateGuildBattlePlusApply, self);
    ListenEvent(Config.EventType.Union_AllianceJoin_ClosePanel_S2C, self.updateAllianceJoinClosePanelState, self);
    ListenEvent(Config.EventType.Union_AllianceJoin_S2C, self.showJoinSucEffect, self);
    ListenEvent(Config.EventType.Union_AllianceInfoList_S2C, self.showAllianceInfoList, self);
    self.isClosePanel = false;
    self:showAllianceTips();
end

function UIGuildSkin:OnDestroy()
    ------------------ fgui事件移除start ------------------
    self:beforeDestroy();
    self.btnBack.onClick:Clear();
    self.btn_Guildhall.onClick:Clear();
    self.btn_gvg[EnumConst.GuildBattlePlusType.Championship].onClick:Clear();
    self.btn_gvg[EnumConst.GuildBattlePlusType.Territory].onClick:Clear();
    self.bgclose.onClick:Clear();
    self.activeTipBtn1.onClick:Clear();
    self.activeTipBtn2.onClick:Clear();
    self.go.onClick:Clear();
    self.btn_Guildleader.onClick:Clear();
    self.btn_Guildshop.onClick:Clear();
    self.btn_Guildinvestment.onClick:Clear();
    self.btn_Guildwish.onClick:Clear();
    self.BtnRank.onClick:Clear();
    self.BtnGift.onClick:Clear();
    self.BtnRobList.onClick:Clear()
    self.BtnRegistration.onClick:Clear()
    self.btn_guild_tech.onClick:Clear()
    self.BtnGuildTask.onClick:Clear()
    ------------------  fgui事件移除end  ------------------
end

function UIGuildSkin:onTouch_BtnBack(obj)
end

function UIGuildSkin:onTouch_Btn_Guildhall(obj)
    unionHandler.reqUnionInfoMessage()
end
function UIGuildSkin:OpenGuildPanel()
    if self.isClosePanel then
        self.isClosePanel = false;
        return;
    end
    if logicMgr.GuildManager.unionInfo then
        showUI(PanelNames.UIGuildPanel);
    end
end
function UIGuildSkin:onTouch_Btn_gvg(obj)
    --UISysTips.AddMsg("暂未开放");
    --return
    if self.last_draw_skill_time and UnityEngineTime.realtimeSinceStartup - self.last_draw_skill_time < 1 then
        --点太快会触发多次
        return
    end
    self.last_draw_skill_time = UnityEngineTime.realtimeSinceStartup
    self.fightTipsController.selectedIndex = 0;
    if logicMgr.FuncOpenManager.isOpen(Config.FuncOpenType.GuildBattle, true, self.btn_gvg[EnumConst.GuildBattlePlusType.Championship]) then
        --unionWarHandler.reqUnionWarInfo(1);
        --if logicMgr.GuildBattlePlusManager.getOpenState() == nil then
        unionWarPlusHandler.reqGuildBattleInfo(1, EnumConst.GuildBattlePlusType.Championship);
        --else
        --    logicMgr.GuildBattlePlusManager.showUnionWarUI();
    end
    --end
end

function UIGuildSkin:onTouch_Btn_Guildcitybattle(obj)
    if logicMgr.FuncOpenManager.isOpen(Config.FuncOpenType.GuildBattlePlus, true, self.btn_gvg[EnumConst.GuildBattlePlusType.Territory]) then
        unionWarPlusHandler.reqGuildBattleInfo(1, EnumConst.GuildBattlePlusType.Territory);
    end
end

function UIGuildSkin:onTouch_Btn_Guildleader(obj)
    showUI(PanelNames.UIGuildBoss)
end

function UIGuildSkin:onTouch_Btn_Guildshop(obj)
    if logicMgr.FuncOpenManager.isOpen(Config.FuncOpenType.EquipShop, true, self.com_Guildshop) then
        showUI(PanelNames.UIShop, EnumConst.ShopType.honorShop, nil, 1);
    end
end

function UIGuildSkin:onTouch_Btn_Guildinvestment(obj)
    UISysTips.AddMsg("暂未开放");
    return
    --showUI(PanelNames.UIGuildInvestment)
end

function UIGuildSkin:onTouch_Btn_Guildwish(obj)
    showUI(PanelNames.UIGuildWish)
end

function UIGuildSkin:onTouch_BtnRank(obj)
    showUI(PanelNames.UIGuildRanking)
end

function UIGuildSkin:onTouch_BtnGift(obj)
    showUI(PanelNames.UIGuildGift)
end

function UIGuildSkin:onTouch_BtnRobList(obj)
    showUI(PanelNames.UIGuildRescue)
end

function UIGuildSkin:onTouch_BtnRegistration(obj)
    logicMgr.GuildBattlePlusManager.closeAndOpenUIScene(true)
end

function UIGuildSkin:onTouch_BtnGuildTech(obj)
    showUI(PanelNames.UIGuildTech)
end

function UIGuildSkin:onTouch_BtnGuildTask(obj)
    showUI(PanelNames.UIGuildTask)
end

function UIGuildSkin:onTouch_BtnActiveTip2(obj)
    -- 圣城之战(领地战)
    GuildBattlePlusManager.setNowType( EnumConst.GuildBattlePlusType.Territory)
    showUI(PanelNames.UIGuildBattlePlusTips);
end

function UIGuildSkin:onTouch_BtnActiveTip1(obj)
     -- 浮岛争霸(争霸赛)
    GuildBattlePlusManager.setNowType( EnumConst.GuildBattlePlusType.Championship)
    showUI(PanelNames.UIGuildBattlePlusTips);
end


------------------  ↑ fgui事件句柄 ↑  ------------------

function UIGuildSkin:setCloseCallback(func, target)
    self.btnBack.onClick:Add(func, target);
end

function UIGuildSkin:beforeDestroy()
    self.com_Guildhall.onClick:Clear();
    self.com_gvg.onClick:Clear();
    self.com_Guildleader.onClick:Clear();
    self.com_Guildshop.onClick:Clear();
    self.com_Guildinvestment.onClick:Clear();
    self.com_Guildwish.onClick:Clear();
    self.btnBackground.onClick:Clear();
    UIRedDots.removeViewEvent(PanelResNames.UIGuild);
    CloseEvent(Config.EventType.Fresh_UnionWarBaseInfo, self.updateGuildBattleState, self);
    CloseEvent(Config.EventType.Fresh_UnionWarPlusBaseInfo, self.updateGuildBattlePlusState, self);
    CloseEvent(Config.EventType.GuildGiftRefresh, self.updateShowGiftBtn, self);
    CloseEvent(Config.EventType.Union_Info_Change, self.OpenGuildPanel, self);
    CloseEvent(Config.EventType.Fresh_UnionWarPlusQualification, self.updateGuildBattlePlusApply, self);
    CloseEvent(Config.EventType.Union_AllianceJoin_S2C, self.showJoinSucEffect, self);
    CloseEvent(Config.EventType.Union_AllianceJoin_ClosePanel_S2C, self.updateAllianceJoinClosePanelState, self);
    CloseEvent(Config.EventType.Union_AllianceInfoList_S2C, self.showAllianceInfoList, self);
    self.GBTimer = self.GBTimer or {};
    for k, v in pairs(self.GBTimer) do
        utimer.remove(v);
    end
    self.GBTimer = nil;
    self:DestoryTimer();
end

function UIGuildSkin:updateGuildBattleState()
    local unionWarState, unionWarStateEndTime = logicMgr.GuildBattleManager.getOpenState();
    local isHaveQualification = logicMgr.GuildBattleManager.getQualification();
    local str = getLanguage("Email_Content205");
    local temp = os.date("%w", math.floor(unionWarStateEndTime));
    if temp == 0 then
        temp = 7;
    end
    if unionWarStateEndTime - HelperFunc.GetServerTime() > temp * 60 * 60 * 24 then
        str = getLanguage("Email_Content209");
    end
    self.btn_gvg[EnumConst.GuildBattlePlusType.Championship]:GetController("tips").selectedIndex = 1;
    if unionWarState == EnumConst.GuildBattleState.Apply then
        if isHaveQualification == 0 then
            str = getLanguage("Email_Content206");
        else
            str = getLanguage("Email_Content207");
        end
    elseif unionWarState == EnumConst.GuildBattleState.Fight then
        if isHaveQualification == 0 then
            str = getLanguage("Email_Content206");
        else
            str = getLanguage("Email_Content208");
        end
    end
    self.btn_gvg[EnumConst.GuildBattlePlusType.Championship]:GetChild("tips").text = str;
end
function UIGuildSkin:updateGuildBattlePlusApply()
    if logicMgr.GuildBattlePlusManager.getGuildApply() == 1 then
        if logicMgr.GuildBattlePlusManager.getQualification(EnumConst.GuildBattlePlusType.Championship) == 1 then
            self.Registration.selectedIndex = 2
        else
            self.Registration.selectedIndex = 0
        end
    else
        self.Registration.selectedIndex = 1
    end
end
function UIGuildSkin:updateShowGiftBtn()
    local giftCount = #logicMgr.GuildManager.GetShowGiftData()
    if giftCount > 0 then
        self.BtnGift.visible = true
    else
        self.BtnGift.visible = false
    end
end

function UIGuildSkin:updateAutoOpenGift()
    local open = logicMgr.GuildManager.GetIsNewGiftIn()
    local giftCount = #logicMgr.GuildManager.GetShowGiftData()
    if open and giftCount > 0 then
        self:onTouch_BtnGift()
    end
end

function UIGuildSkin:updateGuildBattlePlusState(type)
    self.GBTimer = self.GBTimer or {};
    self.GBCountDown = self.GBCountDown or {};
    self.countDownStr = self.countDownStr or {};
    local unionWarState, unionWarStateEndTime = logicMgr.GuildBattlePlusManager.getOpenState(type);
    local openFlag, openTime;
    if type == EnumConst.GuildBattlePlusType.Championship then
        openFlag, openTime = logicMgr.FuncOpenManager.isOpen(Config.FuncOpenType.GuildBattle)
        if unionWarState ~= EnumConst.GuildBattlePlusState.Open then
            self:onTouch_CloseBGPTips();
        end
        if logicMgr.GuildBattlePlusManager.getBattleType(unionWarStateEndTime) == 1 then
            self.btn_gvg[type].text = getLanguage("CommonPop_Title81");
            --self.countDownStr[type] = getLanguage("CommonPop_Title81").."开始:%s";
        else
            self.btn_gvg[type].text = getLanguage("CommonPop_Title80");
            --self.countDownStr[type] = getLanguage("CommonPop_Title80").."开始:%s";
        end
    else
        openFlag, openTime = logicMgr.FuncOpenManager.isOpen(Config.FuncOpenType.GuildBattlePlus)
        self.btn_gvg[type].text = getLanguage("CommonPop_Title82");
    end
    self.countDownStr[type] = "%s后开启";
    if unionWarStateEndTime < HelperFunc.GetServerTime() then
        self.btn_gvg[type]:GetController("tips").selectedIndex = 0;
        return ;
    end
    if unionWarState == EnumConst.GuildBattlePlusState.Open then
        --if type == EnumConst.GuildBattlePlusType.Territory then
        --    self.countDownStr[type] = getLanguage("GuildBattlePlusTips004")
        --elseif type == EnumConst.GuildBattlePlusType.Championship then
        --    self.countDownStr[type] = getLanguage("GuildBattlePlusTips005")
        --end
        self.countDownStr[type] = getLanguage("GuildWarTips_01");
    elseif unionWarState == EnumConst.GuildBattlePlusState.Settlement then
        self.countDownStr[type] = "结算中:%s";
    end
    self.GBCountDown[type] = unionWarStateEndTime - HelperFunc.GetServerTime() + 1;
    if not openFlag and openTime then
        self.GBCountDown[type] = openTime;
        self.countDownStr[type] = "%s后开启";
    end
    self.btn_gvg[type]:GetController("tips").selectedIndex = 1;
    self:OnCountDown(type);
    if self.GBTimer[type] then
        utimer.remove(self.GBTimer[type]);
    end
    self.GBTimer[type] = utimer.timeCall(function()
        self:OnCountDown(type);
    end, 1000, -1)
end
function UIGuildSkin:OnCountDown(type)
    self.GBCountDown[type] = self.GBCountDown[type] - 1;
    self.btn_gvg[type]:GetChild("tips").text = string.format(self.countDownStr[type], HelperFunc.GetTimeStr(self.GBCountDown[type]))
    if self.GBCountDown[type] < 0 then
        self:updateGuildBattlePlusState(type);
        return true;
    end
end
function UIGuildSkin:showGuildBattlePlusTips()
    local unionWarState, unionWarStateEndTime = logicMgr.GuildBattlePlusManager.getOpenState(EnumConst.GuildBattlePlusType.Championship);
    if logicMgr.FuncOpenManager.isOpen(Config.FuncOpenType.GuildBattle) and unionWarState == EnumConst.GuildBattlePlusState.Open and logicMgr.GuildBattlePlusManager.getQualification(EnumConst.GuildBattlePlusType.Championship) == 1 and logicMgr.GuildBattlePlusManager.getBattleType() == 1 then
        if not GetPlayerPrefsTodayFlag("GuildBattlePlusChampionshipTips") then
            self.fightTipsController.selectedIndex = 1;
            SetPlayerPrefsTodayFlag("GuildBattlePlusChampionshipTips", true);
        end
    end
end
function UIGuildSkin:onTouch_CloseBGPTips()
    self.fightTipsController.selectedIndex = 0;
end

function UIGuildSkin:DestoryTimer()
    if self.mEffectTimer then
        utimer.remove(self.mEffectTimer)
        self.mEffectTimer = nil
    end
end

function UIGuildSkin:updateAllianceJoinClosePanelState(type)
    if tonumber(type) == 1 then
        self.isClosePanel = true;
    end
end
function UIGuildSkin:onTouch_Btn_background(obj)
    self.effectCtrl.selectedIndex = 0;
end
function UIGuildSkin:showJoinSucEffect(type)
    self.isClosePanel = false;
    self.effectCtrl.selectedIndex = 0;
    if tonumber(type) == 1 then
        unionWarPlusHandler.reqGuildBattleInfo(0, EnumConst.GuildBattlePlusType.Territory);
        local unionInfo = logicMgr.GuildManager.unionInfo;
        if unionInfo ~= nil then
            local allianceId = tonumber(unionInfo.allianceId);
            if allianceId > 0 then
                local key = "UIGuildSkin" .. logicMgr.HeroManager.GetRoleInfo().playerId .. "id:" .. allianceId;
                if Util.GetPlayerPrefs(key) == nil then
                    Util.SetPlayerPrefs(key, "true");
                    self.effectReset:Play();
                    -- 播放战团合并动效
                    self.effectCtrl.selectedIndex = 1;
                    self.ldrFlag1.url = logicMgr.GuildManager.getFlagUrl();
                    local itemNum = #logicMgr.GuildManager.db_guildlogo;
                    math.randomseed(os.time());
                    local flagId = math.random(1, itemNum);
                    self.ldrFlag2.url = logicMgr.GuildManager.getFlagUrl(flagId);
                    self:DestoryTimer();
                    self.mEffectTimer = utimer.delayCall(function()
                        AudioManager.Play(2015);
                        self.effectGuildAlly:Play();
                    end, 200);
                end
            end
        end
    end
end

function UIGuildSkin:showAllianceTips()
    local unionInfo = logicMgr.GuildManager.unionInfo;
    if unionInfo ~= nil then
        local createTime = tonumber(tostring(unionInfo.create));
        local temp = os.date("!*t", math.floor(createTime + 8*3600));
        local toTime = createTime - (temp.hour * 60 + temp.min) * 60 - temp.sec + 7 * 24 * 3600;
        local serverTime = HelperFunc.GetServerTime();
        if serverTime < toTime then
            return;
        end

        local globalCount = tonumber(G.dataTable["t_global"]["651"].f_int_value);
        local memberCount = #unionInfo.members;
        if (unionInfo.leader ~= nil) and tostring(unionInfo.leader.showInfo.playerId) == tostring(logicMgr.HeroManager.GetRoleInfo().playerId) and memberCount <= globalCount then
            local key = "showAllianceTips" .. logicMgr.HeroManager.GetRoleInfo().playerId .. "id:"..unionInfo.id;
            local today = tonumber(os.date("%w",serverTime));
            if today == 1 then
                local localState = Util.GetPlayerPrefs(key);
                if localState == nil or tonumber(localState) ~= 1 then
                    Util.SetPlayerPrefs(key, 1);
                    local isClick = false;
                    local pop = CtrlManager.GetCtrl(PanelNames.UICommonPop)
                    pop.Init(117, function (flag)
                        if flag then
                            if isClick then
                                return;
                            end
                            isClick = true;
                            unionHandler.sendReqAllianceInfoList();
                        end
                    end);
                end
            else
                Util.SetPlayerPrefs(key, 0);
            end
        end
    end
end

function UIGuildSkin:showAllianceInfoList()
    if (not isOpenUI(PanelNames.UIGuildPanel)) and (not isOpenUI(PanelNames.UIGuildAllyPanel)) then
        showUI(PanelNames.UIGuildAllyPanel);
    end
end

return UIGuildSkin;
